/*
 * Foogl (Friendly Object Oriented Game Library)
 * Copyright (c) 2008 Wachirawut Thamviset.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


package kku.cs.fgl;

import java.util.Vector;

public class ActorControllerList implements ActorController {
	Vector list=new Vector();
 
	public ActorController [] getArray(){
		ActorController a[]=new ActorController[list.size()];
		list.toArray(a);
		return a;
	}
	public void mouseClicked(Actor actor, int button) {
		ActorController a[] = getArray();
		for(int i=0;i<a.length;i++){
			a[i].mouseClicked(actor, button);
		}
	}

	public void collideIn(Actor actor1, Actor actor2) {
		ActorController a[] = getArray();
		for(int i=0;i<a.length;i++){
			a[i].collideIn(actor1, actor2);
		}
	}

	public void collideOut(Actor actor1, Actor actor2) {
		ActorController a[] = getArray();
		for(int i=0;i<a.length;i++){
			a[i].collideOut(actor1, actor2);
		}
	}

	public void mouseEntered(Actor actor) {
		ActorController a[] = getArray();
		for(int i=0;i<a.length;i++){
			a[i].mouseEntered(actor);
		}
	}

	public void mouseExited(Actor actor) {
		ActorController a[] = getArray();
		for(int i=0;i<a.length;i++){
			a[i].mouseExited(actor);
		}
	}

	public void update(Actor actor, int time) {
		ActorController a[] = getArray();
		for(int i=0;i<a.length;i++){
			a[i].update(actor, time);
		}

	}
  
	public void add(ActorController controller){
	   if(!list.contains(controller))
		   list.add(controller);
	}
	public void remove(ActorController controller){
	    list.remove(controller);
	}
	public void clear() {
		list.clear();
	}
	
}
